import request from '../utils/request';

export function getArticleList(params) {
  return request({
    url: '/v1_0/mp/articles',
    params,
  });
}

export function getChannel() {
  return request({
    url: '/v1_0/channels',
  });
}

export function deleteArticle(id) {
  return request({
    url: '/v1_0/mp/articles/' + id,
    method: 'DELETE',
  });
}

export function addArticle(data, draft = false) {
  return request({
    url: `/v1_0/mp/articles?draft=${draft}`,
    method: 'POST',
    data,
  });
}

export function articleDetail(id) {
  return request({
    url: '/v1_0/mp/articles/' + id,
  });
}

export function editArticle(id, data, draft = false) {
  return request({
    url: `/v1_0/mp/articles/${id}?draft=${draft}`,
    method: 'PUT',
    data,
  });
}
